using System.Collections.Generic;

namespace Webshop20.AntiCorruptionLayers.Lucene
{
    public class ProductFullTextSearchService : IProductFullTextSearchService
    {
        private readonly IProductFullTextSearchFacade facade;
        private readonly IProductIdTranslator translator;

        public ProductFullTextSearchService(IProductFullTextSearchFacade facade, IProductIdTranslator translator)
        {
            this.facade = facade;
            this.translator = translator;
        }

        public IEnumerable<int> LookForProductsWith(string searchTerm)
        {
            var documents = facade.Search(searchTerm);
            return translator.ConvertToProductIds(documents);
        }
    }
}